<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Ecard extends MY_Controller {
    function __construct()
    {
        parent::__construct();
        $this->__validation();
        $this->load->model('Account_model','Account');
    }
    public function index()
    {
        $this->_display();
    }
    private function _display()
    {
        $uid = $this->params['uid'];
        $rtn = $this->Account->getUserECard($this->params['uid']);

        
        if($rtn)
        {
            $this->load->library('ecardcore',array('code'=>$rtn->code,'sn'=>$rtn->sn));
            $this->ecardcore->uid=$uid;
            $this->ecardcore->sn=$rtn->sn;
            $this->ecardcore->code=$rtn->code;
            $this->ecardcore->generateCode();
            $this->ecardcore->generateSN();
            $this->ecardcore->expire=date('Y-m-d',$rtn->createtime+$rtn->expire*86400);
            $this->ecardcore->display();
        }
        else
        {
            show_404();
        }
    }
}